<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自由讨论</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style type="text/css" >

        #first{
            margin: 0 auto;
            width: 950px;
            background-color: #F6F6F8;
        }
    </style>
</head>
<body>
<div id="first">

</div>
<script>

    window.onload = function () {
        var topic = localStorage.getItem("topic");
        var publisherId = localStorage.getItem("publisherId");
        $.ajax({
            url:'http://106.14.215.182:9091/tby/ipos-discussion-publisher/getContext',
            type:"POST",
            data:JSON.stringify({
                topic:topic,
                publisherId:publisherId,
                returnContent:''
            }),
            contentType: 'application/json',
            dataType: 'json',
            success:function (result) {
                console.log(result)
                var tbody = $("#first");
                $('#first').empty();
                var data = result.data;
                var obj1 = new Object();
                var obj2 = new Object();
                if(data.context.length == 0){
                    var html1 ='';
                    html1 = html1+'<div style="height: 100px">\n' +
                        '                    <div style="padding-top: 20px;padding-left: 20px">\n' +
                        '                    <p style="color: red;display: inline-block">发表人: '+publisherId+'</p>\n' +
                        '                    <p style="display: inline-block;font-size: 18px;margin-left: 50px "><a  style="color:#2D64B3">'+topic+'</a></p>\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '                <hr>';
                    tbody.append(html1);
                    tbody.innerHTML = html1;
                }
                for(var i =0 ;i<data.context.length;i++){
                    var html1 ='';
                    obj1[i] = data.context[i];
                    obj2[i] = data.returnUserId[i];
                    if(i == 0){
                        html1 = html1+'<div style="height: 100px">\n' +
                            '                    <div style="padding-top: 20px;padding-left: 20px">\n' +
                            '                    <p style="color: red;display: inline-block">发表人: '+publisherId+'</p>\n' +
                            '                    <p style="display: inline-block;font-size: 18px;margin-left: 50px "><a  style="color:#2D64B3">'+topic+'</a></p>\n' +
                            '                    </div>\n' +
                            '                </div>\n' +
                            '                <hr>';
                    }
                    var html =html1+  '<div style="height: 100px">\n' +
                        '                    <div style="padding-top: 20px;padding-left: 20px">\n' +
                        '                    <p style="color: red;display: inline-block">回复人: '+obj2[i]+'</p>\n' +
                        '                    <p style="display: inline-block;font-size: 18px;margin-left: 50px "><a  style="color:#2D64B3">'+obj1[i]+'</a></p>\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '                <hr>';
                    tbody.append(html);
                    tbody.innerHTML = html;
                }
            }
        })
    }
</script>
</body>
</html>